﻿
//
//
//

namespace Microsoft.OpenTurf.Silverlight.Shared
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;

    public class EnumHelper
    {
        public static List<T> EnumToList<T>()
        {
            Type enumType = typeof(T);

            if (!enumType.IsEnum)
                throw new InvalidCastException(@"'T' is not of type 'Enum'");

            return new List<T>((from field in enumType.GetFields()
                                where field.IsLiteral
                                select field.GetValue(enumType)) as IEnumerable<T>);
        }
    }
}
